package org.soc.timesheet.server.domain.service;

import java.util.List;
import java.util.Set;

import org.soc.timesheet.domain.Emails;
import org.soc.timesheet.domain.repository.EmailsRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class EmailsServiceImpl implements EmailsService {

	
	@Autowired
	EmailsRepository emailsRepository;
	
	public long countAllEmailses() {
        return Emails.countEmailses();
    }

	public void deleteEmails(Emails emails) {
        emails.remove();
    }

	public Emails findEmails(Integer id) {
        return Emails.findEmails(id);
    }

	public List<Emails> findAllEmailses() {
        return Emails.findAllEmailses();
    }

	public List<Emails> findEmailsEntries(int firstResult, int maxResults) {
        return Emails.findEmailsEntries(firstResult, maxResults);
    }

	public void saveEmails(Emails emails) {
        emails.persist();
    }

	public Emails updateEmails(Emails emails) {
        return emails.merge();
    }

	@Override
	public Page<Emails> findByIdUser(int idUser, PageRequest pageRequest) {
		// TODO Auto-generated method stub
		return emailsRepository.findByIdUsers(idUser,pageRequest);
	}

	@Override
	public void saveAll(Set<Emails> emailss) {
		emailsRepository.save(emailss);		
	}
}
